package com.gongyi.advance;

public class TestUnLock {
    public static void main(String[] args) {
        TestUnLock2 testUnLock2 = new TestUnLock2();

        new Thread(testUnLock2).start();
        new Thread(testUnLock2).start();
        new Thread(testUnLock2).start();

    }
}

class TestUnLock2 implements Runnable {
    int ticketNums = 10;

    @Override
    public void run() {
        while (true) {
            if (ticketNums > 0) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(ticketNums--);
            } else {
                break;
            }
        }
    }
}
